package com.zh.springcloud.controller;

import com.zh.springcloud.common.Result;
import com.zh.springcloud.entity.Payment;
import com.zh.springcloud.service.PaymentService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @ClassName PaymentController
 * @date: 2021.06.08 15:50
 * @Author: zhanghang
 */
@RequestMapping("payment")
@RestController
@Slf4j
public class PaymentController {

	@Autowired
	private PaymentService paymentService;

	@Value("${server.port}")
	private String serverPort;

	@PostMapping("save")
	@ApiOperation(value = "添加订单")
	public Result<?> savePayment(@RequestBody Payment payment){
		log.info("===========插入==========serverPort:"+serverPort);
		return paymentService.savePayment(payment);
	}

	@GetMapping("/{id}")
	@ApiOperation(value = "获取订单")
	public Result<?> getPaymentById(@PathVariable Long id){
		Result<Object> result = new Result<>();
		log.info("============查询=========serverPort:"+serverPort);
		result.setResult(paymentService.getPaymentById(id));
		return result;
	}


}
